package mebp.genetic.selection;

import java.util.Iterator;
import mebp.genetic.Individuum;

import mebp.genetic.Population;
import mebp.genetic.recombination.RecombinationStrategy;

public class GreedySelection implements SelectionStrategy {

	@Override
	public void selectionAndRecombination(Population population,
			Population nextgen, RecombinationStrategy recombination) {
		int count=population.getSize();
		Iterator<Individuum> i=population.iterator();
		while (nextgen.getSize()<count) {
			if (!i.hasNext()) i=population.iterator();
			Individuum i1=(Individuum)i.next();
			if (!i.hasNext()) i=population.iterator();
			Individuum i2=(Individuum)i.next();
			
			nextgen.add(recombination.recombine(i1,i2));
		}
	}

}
